package com.cjkj.system.api.factory;

import com.cjkj.common.core.domain.R;
import com.cjkj.system.api.RemoteTJ01DataService;
import com.cjkj.system.api.RemoteTJ02DataService;
import com.cjkj.system.api.domain.APIMonitorPadData;
import com.cjkj.system.api.domain.MonitorPadRecords;
import com.cjkj.system.api.domain.SleepStageRecords;
import com.cjkj.system.api.domain.SmartBraceletRecords;
import com.cjkj.system.api.domain.request.EquipmentHDAReq;
import com.cjkj.system.api.domain.request.PatientEquipmentRTDReq;
import com.cjkj.system.api.domain.request.RecordsReq;
import com.cjkj.system.api.domain.request.SleepStageReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteTJ01DataServiceFallbackFactory implements FallbackFactory<RemoteTJ01DataService> {

    @Override
    public RemoteTJ01DataService create(Throwable cause) {
        log.error("系统服务调用失败:{}", cause.getMessage());

        return new RemoteTJ01DataService() {
            @Override
            public R<SleepStageRecords> tj01StageRecords(SleepStageReq sleepStageReq, String source) {
                log.error("设备号："
                        +sleepStageReq.getEquipmentNo()+"查询"
                        +sleepStageReq.getStartTime()
                        +"-"
                        +sleepStageReq.getEndTime()
                        +"睡眠状态状态记录失败");
                return R.fail("查询睡眠状态记录失败！");
            }

            @Override
            public R<MonitorPadRecords> tj01Data(RecordsReq req, String source) {
                log.error("设备号："+req.getEquipmentNo()
                        + " 查询使用时间"+ req.getStartTime() + "-" +req.getEndTime()
                        + "的记录失败");
                return R.fail("查询睡眠监测垫记录失败");
            }

            @Override
            public R<APIMonitorPadData> getLastMonitorPadDataInUse(PatientEquipmentRTDReq req, String source) {
                return R.fail(req.getEquipmentNo() + "获取最新数据失败！");
            }

            @Override
            public R<Object> appListEquipmentHDA(EquipmentHDAReq req) {
                return R.fail("获取"+req.getUserId() +" "+req.getEquipmentType()+"的历史记录出错");
            }
        };
    }

}
